$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'test/unit'
RAILS_ENV = "test"
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
require 'action_controller/test_process'
require 'breakpoint'

module Test
  module Unit
    module Assertions
      def assert_recognizes(expected_options, path, extras={}, message=nil)
        request_method = (extras[:method] || :get).to_s
        clean_backtrace do
          path = "/#{path}" unless path[0..0] == '/'

          # Load routes.rb if it hasn't been loaded.
          ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty? 

          # Assume given controller

          request = ActionController::TestRequest.new({}, {}, nil)
          request.path = path
          request.env['REQUEST_METHOD'] = request_method

          ActionController::Routing::Routes.recognize!(request)

          expected_options = expected_options.clone
          extras.each_key { |key| expected_options.delete key } unless extras.nil?
          expected_options.stringify_keys!
          msg = build_message(message, "The recognized options <?> did not match <?>", 
          request.path_parameters, expected_options)
          assert_block(msg) { request.path_parameters == expected_options }
        end
      end
    end
  end
end